<script lang="ts" setup>
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  remove: {
    type: Function, //传入createApp中移除节点的方法
    default: null
  }
})

const show = ref(props.visible)
// 监听显示的消失，需要移除dom
watch(
  () => show.value,
  (val) => {
    !val && props.remove()
  }
)
</script>

<template>
  <el-image-viewer v-if="show" v-bind="$attrs" hide-on-click-modal @close="show = false" />
</template>
